<head>
		<link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
		<link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="/plugins/iCheck/skins/all.css">
		<link rel="stylesheet" href="/plugins/perfect-scrollbar/src/perfect-scrollbar.css">
		<link rel="stylesheet" href="/plugins/animate.css/animate.min.css">
		<!--<link rel="stylesheet" href="/css/styles.css">-->
		<!--<link rel="stylesheet" href="/css/styles-responsive.css">-->
		<link rel="stylesheet" href="/css/plugins.css">
		<link rel="stylesheet" href="/css/lao_111.css">
		<!--<link rel="stylesheet" href="/css/themes/theme-default.css" type="text/css" id="skin_color">-->
		<link rel="stylesheet" href="/css/print.css" type="text/css" media="print"/>
        <link rel="stylesheet" href="/plugins/SweetAlert/sweetalert.css" />
        <link rel="stylesheet" href="/plugins/jquery-ui-1.11.4/jquery-ui.css" />
        <link rel="stylesheet" href="/plugins/datetimepicker/css/bootstrap-datetimepicker.css" />
        <link rel="stylesheet" href="/plugins/webuploader/webuploader.css">
        <!--<link rel="stylesheet" href="/viewer/css/viewer.min.css">-->
        <!--<link rel="stylesheet" href="/css/base.css">-->

		<!-- end: CORE CSS -->
		<link rel="shortcut icon" href="/images/favicon.ico" />
        <script src="/plugins/jQuery/jquery-2.1.1.min.js"></script>
        <script src="/js/fakeloader.min.js"></script>
    
</head>
<div class="main-container inner">
    <div class="main-content">
        <div class="container-fluid">
            <div class="row bt">
                <div class="col-lg-12 bg">
                    <ol class="breadcrumb">
                        <li class="active">
                            <i class="fa  fa-fw fa-reorder"></i>全局设置
                        </li>
                    </ol>
                </div>
            </div>
            <div class="row">
                    <form method="post" enctype="multipart/form-data" name="myform">
                <div class="col-lg-12">
                    <ul id="course-tab" class="nav nav-tabs">
<!-- 基础信息标签页-->
                        <li class="active"> 
                            <a href="#worker-rule" data-toggle="tab">员工考核规则</a> 
                        </li>
<!--课程列表标签页   -->
                        <li>
                            <a href="#times-edit" data-toggle="tab">时间段设置</a> 
                        </li>
<!--音频/视频标签页-->
                        <li class="audio-video">
                            <a href="#audio-video" data-toggle="tab">音频/视频</a> 
                        </li>
                    </ul>
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane fade in active" id="worker-rule">
                            <textarea name="description" value="" cols="100" rows="12"><?=$tOData['description']?>
                            </textarea>
                        </div>
                        <div class="tab-pane fade" id="times-edit">
                            <span>早上</span><input type="text" name="zs_starttime" value="<?=$tOData['zs_starttime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="开始时间"/>——————<input type="text" name="zs_endtime" value="<?=$tOData['zs_endtime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="结束时间"/><br><br>
                            <span>上午</span><input type="text" name="sw_starttime" value="<?=$tOData['sw_starttime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="开始时间"/>——————<input type="text" name="sw_endtime" value="<?=$tOData['sw_endtime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="结束时间"/><br><br>
                            <span>中午</span><input type="text" name="zw_starttime" value="<?=$tOData['zw_starttime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="开始时间"/>——————<input type="text" name="zw_endtime" value="<?=$tOData['zw_endtime']?>" placeholder="结束时间"/><br><br>
                            <span>下午</span><input type="text" name="xw_starttime" value="<?=$tOData['xw_starttime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="开始时间"/>——————<input type="text" name="xw_endtime" value="<?=$tOData['xw_endtime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="结束时间"/><br><br>
                            <span>晚上</span><input type="text" name="ws_starttime" value="<?=$tOData['ws_starttime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="开始时间"/>——————<input type="text" name="ws_endtime" value="<?=$tOData['ws_endtime']?>" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"placeholder="结束时间"/><br>
                        </div>
                        <div class="tab-pane fade" id="audio-video">
                            <button onclick="$('#modal_box').modal('toggle');" type="button" class="btn btn-blue">添加</button>
            <div class="modal fade" id="modal_box" tabindex="-1" role="dialog" aria-labelledby="modal_delLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content" style="width:750px;">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">新增</h4>
                            </div>
                            <div class="modal-body" style="width:750px;">
                                <form method="post" class="addTrain">
                                <span>选择类型：</span>
                                <select name="event_type" id="event_type">
                                    <?php foreach($tEIDatas as $tEIRow){?>
                                    <option value="<?=$tEIRow['num']?>"><?=$tEIRow['introduce']?></option>
                                    <?php }?>
                                </select><br><br>
                                <input type="hidden" name="event_type" class="hideEventtype" value=""/>
                                <div class="space" style="margin-top:10px;"></div>
                                <!--<span>选择音频</span><input type="file" id="picker" value="" name="fileAudio"/><br><br>-->
                                <div id="uploader">
                                    <div class="queueList">
                                        <div id="dndArea" class="placeholder">
                                            <div id="filePicker"></div>
                                            <!--<p>或将文件拖到这里，单次最多可选300张</p>-->
                                        </div>
                                    </div>
                                    <div class="statusBar" style="">
                                        <div class="progress">
                                            <span class="text">0%</span>
                                            <span class="percentage"></span>
                                        </div><div class="info"></div>
                                        <div class="btns">
                                            <div id="filePicker2"></div><div class="uploadBtn btn btn-default">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                                <div class="space" style="margin-top:10px;"></div>
                                <div id="uploader1">
                                    <div class="queueList1">
                                        <div id="dndArea1" class="placeholder">
                                            <div id="filePicker3"></div>
                                            <!--<p>或将文件拖到这里，单次最多可选300张</p>-->
                                        </div>
                                    </div>
                                    <div class="statusBar1" style="">
                                        <div class="progress1">
                                            <span class="text1">0%</span>
                                            <span class="percentage1"></span>
                                        </div><div class="info1"></div>
                                        <div class="btns1">
                                            <div id="filePicker4"></div><div class="uploadBtn1 btn btn-default">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                                <div class="space" style="margin-top:10px;"></div>
                                <span>视频标题：</span><input type="text" name="title" value="" placeholder="请输入视频标题"/><br><br>
                                <div class="space" style="margin-top:10px;"></div>
                                <span>备注：</span></br>
                                <div class="space" style="margin-top:10px;"></div>
                                <textarea name="remarks" value="" style="margin-left:54px;width:450px;"></textarea></br>
                            </div>
                            <div class="modal-footer">
                                <button class="addBtn btn btn-danger btn-sm ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
                                    <span class="ui-button-text">
                                        <i class="icon-ok bigger-110"></i>
                                        确 定
                                    </span>
                                </button>
                                <button class="btn btn-sm ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false" data-dismiss="modal">
                                    <span class="ui-button-text">
                                        <i class="icon-remove bigger-110"></i>
                                        取 消
                                    </span>
                                </button>
                            </div>
                            </form>
                        </div>
                    </div>
                </div>
                            <table class="table table-hover" id="table_list">
                                <thead>
                                    <tr>
                                        <td>编号</td>
                                        <td>类型</td>
                                        <td>音频</td>
                                        <td>视频</td>
                                        <td>备注</td>
                                        <td>操作</td>
                                    </tr>
                                </thead>
                                <?foreach($tEMDatas as $tRow){?>
                                    <tr>
                                        <td><?=$tRow['id']?></td>
                                        <td><?=$tRow['event_type']?></td>
                                        <td><a href="<?=$tRow['audio']?>"><?=$tRow['audio_title']?></a></td>
                                        <td><a href="<?=$tRow['video']?>"><?=$tRow['video_title']?></a></td>
                                        <td><?=$tRow['remarks']?></td>
    <td>
        <div class="visible-md visible-lg hidden-sm hidden-xs">
                                <a href="#"  onclick="cg_confirm_del('/admin_overall/delete?id=<?=$tRow['id']?>','/admin_overall')" class="btn btn-orange btn-xs tooltips demo_4" data-placement="top" data-original-title="删除"><i class="fa fa-times"></i></a>
        </div>
    </td>
                                    </tr>
                                <?}?>
                            </table>
                        </div> 
                    </div>
                </div>
                <div class="edit col-lg-12" style="margin-left:20px;margin-top:200px;">
                        <button class="btn btn-primary demo_2" type="button" id="submit">修改</button>
                </div>
                <div class="subviews">
                    <div class="subviews-container"></div>
                </div>
            </div>
                    </form>   
            <!-- end: PAGE -->
            <?=$tShow?>
        </div>
    </div>
</div>
<!-- end: MAIN CONTAINER -->
<script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="/plugins/jquery-ui-1.11.4/jquery-ui.min.js"></script>
 <script type="text/javascript" src="/plugins/webuploader/webuploader.min.js"></script><!--zepto -->
<script>
(function( $ ){
        var event_type = '';
        // 当domReady的时候开始初始化
        $(function() {
            var $wrap = $('#uploader');
            // 状态栏，包括进度和控制按钮
                    $statusBar = $wrap.find( '.statusBar' ),

            // 文件总体选择信息。
                    $info = $statusBar.find( '.info' ),

            // 上传按钮
                    $upload = $wrap.find( '.uploadBtn' ),

            // 没选择文件之前的内容。
                    $placeHolder = $wrap.find( '.placeholder' ),

                    $progress = $statusBar.find( '.progress' ).hide(),

            // 添加的文件数量
                    fileCount = 0,

            // 添加的文件总大小
                    fileSize = 0,

            // 优化retina, 在retina下这个值是2
                    ratio = window.devicePixelRatio || 1,

            // 缩略图大小
                    thumbnailWidth = 110 * ratio,
                    thumbnailHeight = 110 * ratio,

            // 可能有pedding, ready, uploading, confirm, done.
                    state = 'pedding',

            // 所有文件的进度信息，key为file id
                    percentages = {},
            // 检测是否已经安装flash，检测flash的版本
                    flashVersion = ( function() {

                        var version;
                        //console.log('flashVersion1开始');

                        try {
                            version = navigator.plugins[ 'Shockwave Flash' ];
                            version = version.description;
                        } catch ( ex ) {
                            try {
                                version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
                                        .GetVariable('$version');
                            } catch ( ex2 ) {
                                version = '0.0';
                            }
                        }
                        version = version.match( /\d+/g );
                        //console.log('flashVersion1结束');
                        return parseFloat( version[ 0 ] + '.' + version[ 1 ], 10 );

                    } )(),

                    supportTransition = (function(){
                        var s = document.createElement('p').style,
                                r = 'transition' in s ||
                                        'WebkitTransition' in s ||
                                        'MozTransition' in s ||
                                        'msTransition' in s ||
                                        'OTransition' in s;
                        s = null;
                        return r;
                    })(),

            // WebUploader实例
            uploader;
            $('#modal_box').on('shown.bs.modal',function(){
            // 实例化
            uploader = WebUploader.create({
                pick: {
                    id: '#filePicker',
                    label: '点击选择音频'
                },
                /*formData: {
                    // uid: "{$Think.session.loginuid}",
                    event_type:eventtype(),
            },*/
                dnd: '#dndArea',
                paste: '#uploader',
                swf: '/plugins/webuploader/Uploader.swf',
                chunked: true,
                chunkSize:2 * 1024 * 1024,
                server: 'http://lyl.fzzj.huayan360.com/apiv1_fileupload/websavefile',
                // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候，把图片打开。
                disableGlobalDnd: true,
                fileNumLimit: 300,
            });
            // 拖拽时不接受 js, txt 文件。
            uploader.on( 'dndAccept', function( items ) {
                var denied = false,
                        len = items.length,
                        i = 0,
                // 修改js类型
                        unAllowed = 'text/plain;application/javascript ';

                for ( ; i < len; i++ ) {
                    // 如果在列表里面
                    if ( ~unAllowed.indexOf( items[ i ].type ) ) {
                        denied = true;
                        break;
                    }
                }
                return !denied;
            });
                $('select[name="event_type"]').on('change',function(){
            uploader.on('ready', function() {
                //window.uploader = uploader;
                    $('.hideEventtype').val($(this).val());
                    uploader;
                });
            });
            //当文件被加入队列之前触发
            uploader.on('beforeFileQueued', function (file) {
                var event_type = $('select[name="event_type"]').val();
                uploader.options.formData= { "event_type": event_type };
            }); 

            // 当有文件添加进来时执行，负责view的创建
            function addFile( file ) {
                var $li = $( '<li id="' + file.id + '">' +
                                '<p class="title">' + file.name + '</p>' +
                                '<p class="imgWrap"></p>'+
                                '</li>' ),

                        $prgress = $li.find('p.progress span'),
                        $wrap = $li.find( 'p.imgWrap' ),
                        $info = $('<p class="error"></p>'),

                        showError = function( code ) {
                            switch( code ) {
                                case 'exceed_size':
                                    text = '文件大小超出';
                                    break;

                                case 'interrupt':
                                    text = '上传暂停';
                                    break;

                                default:
                                    text = '上传失败，请重试';
                                    break;
                            }

                            $info.text( text ).appendTo( $li );
                        };

                if ( file.getStatus() === 'invalid' ) {
                    showError( file.statusText );
                } else {
                    // @todo lazyload
                    $wrap.text( '预览中' );
                    uploader.makeThumb( file, function( error, src ) {
                        var img;

                        if ( error ) {
                            $wrap.text( '不能预览' );
                            return;
                        }

                        if( isSupportBase64 ) {
                            img = $('<img src="'+src+'">');
                            $wrap.empty().append( img );
                        } else {
                            $.ajax('../../server/preview.php', {
                                method: 'POST',
                                data: src,
                                dataType:'json'
                            }).done(function( response ) {
                                if (response.result) {
                                    img = $('<img src="'+response.result+'">');
                                    $wrap.empty().append( img );
                                } else {
                                    $wrap.text("预览出错");
                                }
                            });
                        }
                    }, thumbnailWidth, thumbnailHeight );

                    percentages[ file.id ] = [ file.size, 0 ];
                    file.rotation = 0;
                }
                var arr='';
                uploader.on( 'uploadSuccess', function(file,text) {
                    arr+=text.fid+',';
                    $('#fid').val(arr);
                    //alert(text.fid);
                    return false;
                });
                file.on('statuschange', function( cur, prev ) {
                    if ( prev === 'progress' ) {
                        $prgress.hide().width(0);
                    } else if ( prev === 'queued' ) {
                        $li.off( 'mouseenter mouseleave' );
                    }

                    // 成功
                    if ( cur === 'error' || cur === 'invalid' ) {
                        showError( file.statusText );
                        percentages[ file.id ][ 1 ] = 1;
                    } else if ( cur === 'interrupt' ) {
                        showError( 'interrupt' );
                    } else if ( cur === 'queued' ) {
                        percentages[ file.id ][ 1 ] = 0;
                    } else if ( cur === 'progress' ) {
                        $info.remove();
                        $prgress.css('display', 'block');
                    } else if ( cur === 'complete' ) {
                        $li.append( '<span class="success"></span>' );
                    }

                    $li.removeClass( 'state-' + prev ).addClass( 'state-' + cur );
                });

                //$li.appendTo( $queue );
            }
            // 负责view的销毁
            function removeFile( file ) {
                var $li = $('#'+file.id);
                delete percentages[ file.id ];
                updateTotalProgress();
                $li.off().find('.file-panel').off().end().remove();
            }
            function updateTotalProgress() {
                var loaded = 0,
                        total = 0,
                        spans = $progress.children(),
                        percent;

                $.each( percentages, function( k, v ) {
                    total += v[ 0 ];
                    loaded += v[ 0 ] * v[ 1 ];
                } );

                percent = total ? loaded / total : 0;


                spans.eq( 0 ).text( Math.round( percent * 100 ) + '%' );
                spans.eq( 1 ).css( 'width', Math.round( percent * 100 ) + '%' );
                updateStatus();
            }

            function updateStatus() {
                var text = '', stats;
                //console.log(ready);
                if ( state === 'ready' ) {
                    text = '选中' + fileCount + '个音频，共' +
                            WebUploader.formatSize( fileSize ) + '。';
                } else if ( state === 'confirm' ) {
                    stats = uploadergetStas();
                    if ( stats.uploadFailNum ) {
                        text = '已成功上传' + stats.successNum+ '个音频文件，'+
                                stats.uploadFailNum + '个音频文件上传失败，<a class="retry" href="#">重新上传</a>失败音频文件或<a class="ignore" href="#">忽略</a>'
                    }

                } else {
                    stats = uploader.getStats();
                    text = '共' + fileCount + '个（' +
                            WebUploader.formatSize( fileSize )  +
                            '），已上传' + stats.successNum + '个';

                    if ( stats.uploadFailNum ) {
                        text += '，失败' + stats.uploadFailNum + '个';
                    }
                }

                $info.html( text );
            }

            function setState( val ) {
                var file, stats;

                if ( val === state ) {
                    return;
                }

                $upload.removeClass( 'state-' + state );
                $upload.addClass( 'state-' + val );
                state = val;

                switch ( state ) {
                    case 'pedding':
                        $placeHolder.removeClass( 'element-invisible' );
                        //$queue.hide();
                        $statusBar.addClass( 'element-invisible' );
                        uploader.refresh();
                        break;

                    case 'ready':
                        $placeHolder.addClass( 'element-invisible' );
                        $( '#filePicker2' ).removeClass( 'element-invisible');
                        //$queue.show();
                        $statusBar.removeClass('element-invisible');
                        uploader.refresh();
                        break;

                    case 'uploading':
                        $( '#filePicker2' ).addClass( 'element-invisible' );
                        $progress.show();
                        $upload.text( '暂停上传' );
                        break;

                    case 'paused':
                        $progress.show();
                        $upload.text( '继续上传' );
                        break;

                    case 'confirm':
                        $progress.hide();
                        $( '#filePicker2' ).removeClass( 'element-invisible' );
                        $upload.text( '开始上传' );

                        stats = uploader.getStats();
                        if ( stats.successNum && !stats.uploadFailNum ) {
                            setState( 'finish' );
                            return;
                        }
                        break;
                    case 'finish':
                        stats = uploader.getStats();
                        if ( stats.successNum ) {
                            alert( '上传成功' );
                        } else {
                            // 没有成功的图片，重设
                            state = 'done';
                            location.reload();
                        }
                        break;
                }

                updateStatus();
            }

            uploader.onUploadProgress = function( file, percentage ) {
                var $li = $('#'+file.id),
                        $percent = $li.find('.progress span');

                $percent.css( 'width', percentage * 100 + '%' );
                percentages[ file.id ][ 1 ] = percentage;
                updateTotalProgress();
            };

            uploader.onFileQueued = function( file ) {
                fileCount++;
                fileSize += file.size;

                if ( fileCount === 1 ) {
                    $placeHolder.addClass( 'element-invisible' );
                    $statusBar.show();
                }

                addFile( file );
                setState( 'ready' );
                updateTotalProgress();
            };

            uploader.onFileDequeued = function( file ) {
                fileCount--;
                fileSize -= file.size;

                if ( !fileCount ) {
                    setState( 'pedding' );
                }

                removeFile( file );
                updateTotalProgress();

            };

            uploader.on( 'all', function( type ) {
                var stats;
                switch( type ) {
                    case 'uploadFinished':
                        setState( 'confirm' );
                        break;

                    case 'startUpload':
                        setState( 'uploading' );
                        break;

                    case 'stopUpload':
                        setState( 'paused' );
                        break;

                }
            });

            uploader.onError = function( code ) {
                alert( 'Eroor: ' + code );
            };

            $upload.on('click', function() {

                if ( $(this).hasClass( 'disabled' ) ) {
                    return false;
                }

                if ( state === 'ready' ) {
                    uploader.upload();
                } else if ( state === 'paused' ) {
                    uploader.upload();
                } else if ( state === 'uploading' ) {
                    uploader.stop();
                }
            });

            $info.on( 'click', '.retry', function() {
                uploader.retry();
            } );

            $info.on( 'click', '.ignore', function() {
                alert( 'todo' );
            } );

            $upload.addClass( 'state-' + state );
            updateTotalProgress();
            });
            //关闭模态框销毁WebUploader，解决再次打开模态框时按钮越变越大问题
            $('#modal_box').on('hide.bs.modal', function () {
                $("#responeseText").text("");
                uploader.destroy();
            });
        });
        $(function() {
            var $wrap1 = $('#uploader1');
            // 状态栏，包括进度和控制按钮
                    $statusBar1 = $wrap1.find( '.statusBar1' ),

            // 文件总体选择信息。
                    $info1 = $statusBar1.find( '.info1' ),

            // 上传按钮
                    $upload1 = $wrap1.find( '.uploadBtn1' ),

            // 没选择文件之前的内容。
                    $placeHolder1 = $wrap1.find( '.placeholder1' ),

                    $progress1 = $statusBar1.find( '.progress1' ).hide(),

            // 添加的文件数量
                    fileCount1 = 0,

            // 添加的文件总大小
                    fileSize1 = 0,

            // 优化retina, 在retina下这个值是2
                    ratio1 = window.devicePixelRatio || 1,

            // 缩略图大小
                    thumbnailWidth = 110 * ratio,
                    thumbnailHeight = 110 * ratio,

            // 可能有pedding, ready, uploading, confirm, done.
                    state1 = 'pedding',

            // 所有文件的进度信息，key为file id
                    percentages1 = {},
            // 检测是否已经安装flash，检测flash的版本
                    flashVersion = ( function() {

                        var version;
                        //console.log('flashVersion1开始');

                        try {
                            version = navigator.plugins[ 'Shockwave Flash' ];
                            version = version.description;
                        } catch ( ex ) {
                            try {
                                version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
                                        .GetVariable('$version');
                            } catch ( ex2 ) {
                                version = '0.0';
                            }
                        }
                        version = version.match( /\d+/g );
                        //console.log('flashVersion1结束');
                        return parseFloat( version[ 0 ] + '.' + version[ 1 ], 10 );

                    } )(),

                    supportTransition = (function(){
                        var s = document.createElement('p').style,
                                r = 'transition' in s ||
                                        'WebkitTransition' in s ||
                                        'MozTransition' in s ||
                                        'msTransition' in s ||
                                        'OTransition' in s;
                        s = null;
                        return r;
                    })(),

            // WebUploader实例
            uploader1;

            if ( !WebUploader.Uploader.support('flash') && WebUploader.browser.ie ) {

                // flash 安装了但是版本过低。
                if (flashVersion) {
                    (function(container) {
                        window['expressinstallcallback'] = function( state1 ) {
                            switch(state1) {
                                case 'Download.Cancelled':
                                    alert('您取消了更新！')
                                    break;

                                case 'Download.Failed':
                                    alert('安装失败')
                                    break;

                                default:
                                    alert('安装已成功，请刷新！');
                                    break;
                            }
                            delete window['expressinstallcallback'];
                        };

                        var swf1 = '/plugins/webuploader/Uploader.swf';
                        // insert flash object
                        var html1 = '<object type="application/' +
                                'x-shockwave-flash" data="' +  swf + '" ';

                        if (WebUploader.browser.ie) {
                            html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
                        }

                        html1 += 'width="100%" height="100%" style="outline:0">'  +
                                '<param name="movie" value="' + swf + '" />' +
                                '<param name="wmode" value="transparent" />' +
                                '<param name="allowscriptaccess" value="always" />' +
                                '</object>';

                        container.html(html1);

                    })($wrap1);

                    // 压根就没有安转。
                } else {
                    $wrap1.html('<a href="http://www.adobe.com/go/getflashplayer" target="_blank" border="0"><img alt="get flash player" src="http://www.adobe.com/macromedia/style_guide/images/160x41_Get_Flash_Player.jpg" /></a>');
                }

                return;
            } else if (!WebUploader.Uploader.support()) {
                alert( 'Web Uploader 不支持您的浏览器！');
                return;
            }
            $("#modal_box").on("shown.bs.modal",function(){
            // 实例化
            uploader1 = WebUploader.create({
                pick: {
                    id: '#filePicker3',
                    label: '点击选择视频'
                },
                /*formData: {
                    // uid: "{$Think.session.loginuid}",
                    event_type:eventtype(),
            },*/
                dnd: '#dndArea1',
                paste: '#uploader1',
                swf: '/plugins/webuploader/Uploader.swf',
                chunked: true,
                chunkSize:2 * 1024 * 1024,
                server: 'http://lyl.fzzj.huayan360.com/apiv1_fileupload/websavefile',
                // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候，把图片打开。
                disableGlobalDnd: true,
                fileNumLimit: 300,
            });
            // 拖拽时不接受 js, txt 文件。
            uploader1.on( 'dndAccept', function( items ) {
                var denied = false,
                        len = items.length,
                        i = 0,
                // 修改js类型
                        unAllowed = 'text/plain;application/javascript ';

                for ( ; i < len; i++ ) {
                    // 如果在列表里面
                    if ( ~unAllowed.indexOf( items[ i ].type ) ) {
                        denied = true;
                        break;
                    }
                }
                return !denied;
            });
                $('select[name="event_type"]').on('change',function(){
            uploader1.on('ready', function() {
                //window.uploader = uploader;
                    $('.hideEventtype').val($(this).val());
                    uploader1;
                });
            });
            //当文件被加入队列之前触发
            uploader1.on('beforeFileQueued', function (file1) {
                var event_type = $('select[name="event_type"]').val();
                uploader1.options.formData= { "event_type": event_type };
            }); 

            // 当有文件添加进来时执行，负责view的创建
            function addFile1( file1 ) {
                var $li1 = $( '<li id="' + file1.id + '">' +
                                '<p class="title">' + file1.name + '</p>' +
                                '<p class="imgWrap"></p>'+
                                '</li>' ),

                        $prgress1 = $li1.find('p.progress1 span'),
                        $wrap1 = $li1.find( 'p.imgWrap1' ),
                        $info1 = $('<p class="error"></p>'),

                        showError1 = function( code ) {
                            switch( code ) {
                                case 'exceed_size':
                                    text = '文件大小超出';
                                    break;

                                case 'interrupt':
                                    text = '上传暂停';
                                    break;

                                default:
                                    text = '上传失败，请重试';
                                    break;
                            }

                            $info1.text( text ).appendTo( $li1 );
                        };

                if ( file1.getStatus() === 'invalid' ) {
                    showError1( file1.statusText );
                } else {
                    // @todo lazyload
                    $wrap1.text( '预览中' );
                    uploader1.makeThumb( file1, function( error, src ) {
                        var img;

                        if ( error ) {
                            $wrap1.text( '不能预览' );
                            return;
                        }

                        if( isSupportBase64 ) {
                            img = $('<img src="'+src+'">');
                            $wrap1.empty().append( img );
                        } else {
                            $.ajax('../../server/preview.php', {
                                method: 'POST',
                                data: src,
                                dataType:'json'
                            }).done(function( response ) {
                                if (response.result) {
                                    img = $('<img src="'+response.result+'">');
                                    $wrap1.empty().append( img );
                                } else {
                                    $wrap1.text("预览出错");
                                }
                            });
                        }
                    }, thumbnailWidth, thumbnailHeight );

                    percentages1[ file1.id ] = [ file1.size, 0 ];
                    file1.rotation = 0;
                }
                var arr1='';
                uploader1.on( 'uploadSuccess', function(file1,text) {
                    arr1+=text.fid+',';
                    $('#fid').val(arr1);
                    //alert(text.fid);
                    return false;
                });
                file1.on('statuschange', function( cur, prev ) {
                    if ( prev === 'progress' ) {
                        $prgress1.hide().width(0);
                    } else if ( prev === 'queued' ) {
                        $li1.off( 'mouseenter mouseleave' );
                    }

                    // 成功
                    if ( cur === 'error' || cur === 'invalid' ) {
                        showError1( file1.statusText );
                        percentages1[ file1.id ][ 1 ] = 1;
                    } else if ( cur === 'interrupt' ) {
                        showError1( 'interrupt' );
                    } else if ( cur === 'queued' ) {
                        percentages1[ file1.id ][ 1 ] = 0;
                    } else if ( cur === 'progress' ) {
                        $info1.remove();
                        $prgress1.css('display', 'block');
                    } else if ( cur === 'complete' ) {
                        $li1.append( '<span class="success"></span>' );
                    }

                    $li1.removeClass( 'state-' + prev ).addClass( 'state-' + cur );
                });

                //$li.appendTo( $queue );
            }
            // 负责view的销毁
            function removeFile1( file1 ) {
                var $li = $('#'+file1.id);
                delete percentages1[ file1.id ];
                updateTotalProgress1();
                $li1.off().find('.file-panel').off().end().remove();
            }
            function updateTotalProgress1() {
                var loaded = 0,
                        total = 0,
                        spans = $progress1.children(),
                        percent1;

                $.each( percentages1, function( k, v ) {
                    total += v[ 0 ];
                    loaded += v[ 0 ] * v[ 1 ];
                } );

                percent1 = total ? loaded / total : 0;


                spans.eq( 0 ).text( Math.round( percent1 * 100 ) + '%' );
                spans.eq( 1 ).css( 'width', Math.round( percent1 * 100 ) + '%' );
                updateStatus1();
            }

            function updateStatus1() {
                var text1 = '', stats;
                //console.log(ready);
                if ( state1 === 'ready' ) {
                    text1 = '选中' + fileCount1 + '个视频，共' +
                            WebUploader.formatSize( fileSize1 ) + '。';
                } else if ( state1 === 'confirm' ) {
                    stats1 = uploader1.getStats();
                    if ( stats1.uploadFailNum ) {
                        text = '已成功上传' + stats1.successNum+ '个视频文件，'+
                                stats1.uploadFailNum + '个视频文件上传失败，<a class="retry" href="#">重新上传</a>失败视频文件或<a class="ignore" href="#">忽略</a>'
                    }

                } else {
                    stats1 = uploader1.getStats();
                    text1 = '共' + fileCount1 + '个（' +
                            WebUploader.formatSize( fileSize1 )  +
                            '），已上传' + stats1.successNum + '个';

                    if ( stats1.uploadFailNum ) {
                        text1 += '，失败' + stats1.uploadFailNum + '个';
                    }
                }

                $info1.html( text1 );
            }

            function setState1( val1 ) {
                var file1, stats1;

                if ( val1 === state1 ) {
                    return;
                }

                $upload1.removeClass( 'state-' + state1 );
                $upload1.addClass( 'state-' + val1 );
                state1 = val1;

                switch ( state1 ) {
                    case 'pedding':
                        $placeHolder1.removeClass( 'element-invisible' );
                        //$queue.hide();
                        $statusBar1.addClass( 'element-invisible' );
                        uploader1.refresh();
                        break;

                    case 'ready':
                        $placeHolder1.addClass( 'element-invisible' );
                        $( '#filePicker4' ).removeClass( 'element-invisible');
                        //$queue.show();
                        $statusBar1.removeClass('element-invisible');
                        uploader1.refresh();
                        break;

                    case 'uploading':
                        $( '#filePicker4' ).addClass( 'element-invisible' );
                        $progress1.show();
                        $upload1.text( '暂停上传' );
                        break;

                    case 'paused':
                        $progress1.show();
                        $upload1.text( '继续上传' );
                        break;

                    case 'confirm':
                        $progress1.hide();
                        $( '#filePicker4' ).removeClass( 'element-invisible' );
                        $upload1.text( '开始上传' );

                        stats1 = uploader1.getStats();
                        if ( stats1.successNum && !stats1.uploadFailNum ) {
                            setState1( 'finish' );
                            return;
                        }
                        break;
                    case 'finish':
                        stats1 = uploader1.getStats();
                        if ( stats1.successNum ) {
                            alert( '上传成功' );
                        } else {
                            // 没有成功的图片，重设
                            state1 = 'done';
                            location.reload();
                        }
                        break;
                }

                updateStatus1();
            }

            uploader1.onUploadProgress = function( file1, percentage1 ) {
                var $li1 = $('#'+file1.id),
                        $percent1 = $li1.find('.progress1 span');

                $percent1.css( 'width', percentage1 * 100 + '%' );
                percentages1[ file1.id ][ 1 ] = percentage1;
                updateTotalProgress1();
            };

            uploader1.onFileQueued = function( file1 ) {
                fileCount1++;
                fileSize1 += file1.size;

                if ( fileCount1 === 1 ) {
                    $placeHolder1.addClass( 'element-invisible' );
                    $statusBar1.show();
                }

                addFile1( file1 );
                setState1( 'ready' );
                updateTotalProgress1();
            };

            uploader1.onFileDequeued = function( file1 ) {
                fileCount1--;
                fileSize1 -= file1.size1;

                if ( !fileCount1 ) {
                    setState1( 'pedding' );
                }

                removeFile1( file1 );
                updateTotalProgress1();

            };

            uploader1.on( 'all', function( type ) {
                var stats1;
                switch( type ) {
                    case 'uploadFinished':
                        setState1( 'confirm' );
                        break;

                    case 'startUpload':
                        setState1( 'uploading' );
                        break;

                    case 'stopUpload':
                        setState1( 'paused' );
                        break;

                }
            });

            uploader1.onError = function( code ) {
                alert( 'Eroor: ' + code );
            };

            $upload1.on('click', function() {

                if ( $(this).hasClass( 'disabled' ) ) {
                    return false;
                }

                if ( state1 === 'ready' ) {
                    uploader1.upload();
                } else if ( state1 === 'paused' ) {
                    uploader1.upload();
                } else if ( state1 === 'uploading' ) {
                    uploader1.stop();
                }
            });

            $info1.on( 'click', '.retry', function() {
                uploader1.retry();
            } );

            $info1.on( 'click', '.ignore', function() {
                alert( 'todo' );
            } );

            $upload1.addClass( 'state-' + state1 );
            updateTotalProgress1();
            });
            //关闭模态框销毁WebUploader，解决再次打开模态框时按钮越变越大问题
            $('#modal_box').on('hide.bs.modal', function () {
                $("#responeseText").text("");
                uploader1.destroy();
            });
        });
    })( jQuery );
    $('#submit').click(function(){
        var data = $('form[name="myform"]').serialize();
        $.post('/admin_overall',data,function(obj){
                cg_alert_edit(obj,'/admin_overall','/admin_overall');
        });
    });
$('.addBtn').click(function(){
    var event_type = $('select[name="event_type"]').val();
    var title = $('input[name="title"]').val();
    var remarks = $('textarea[name="remarks"]').val();
    $.post('/admin_overall/editmedia',{event_type:event_type,title:title,remarks:remarks},function(obj){
        cg_alert_add(obj,'/admin_overall','/admin_overall');
    });
});
$('.audio-video').click(function(){
    $('.edit').css('display','none');
});


</script>

<?php include PATH_TPL."/admin/tpl.footer.phtml"?>
